﻿using Microsoft.AspNetCore.Http;
using Rhonin.Common;
using Rhonin.Common.Entity.UserTicket;
using Rhonin.Common.Extentions;

namespace ApiManage.Core.Utils
{
    public static class AuthUtils
    {
        /// <summary>
        /// Request内票据对应名称
        /// </summary>
        static readonly string _ticketName = "api-manage-ticket";

        public static UserTicket GetLoginUser(this HttpContext context)
        {
            var requestCookie = context.Request.Cookies[_ticketName];
            return requestCookie == null ? null : Ticket.GetTicket(context.Request.Cookies[_ticketName]);
        }
    }
}
